{% extends "./inc/base.html" %}
{%block style%}
<link rel="stylesheet" href="/static/admin/js/chosen/chosen.css" type="text/css"/>
{%endblock%}
{% block content %}
<section class="vbox">
    <header class="header bg-light dk">
        <p>{{controller.meta_title}}</p>
    </header>
    <section class="scrollable wrapper">
        <div class="row">
            <div class="col-lg-12">
                <section class="panel panel-default">
                    <div class="panel-body">
                        <form id="ajaxForm" method="post" class="form-horizontal" action="/admin/model/addext" data-validate="parsley">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">模型标识</label>

                                <div class="col-sm-10">

                                    <div class="row">
                                        <div class="col-md-4">
                                            <input type="text" class="form-control  " name="name" value="" data-required="true" data-Remote="/admin/model/checkname">
                                        </div>
                                        <div class="col-md-12">
                                            <span class="help-block m-b-none">请输入文档模型标识</span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="line line-dashed b-b line-lg pull-in"></div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">模型名称</label>

                                <div class="col-sm-10">
                                    <div class="row">
                                        <div class="col-md-4">
                                            <input type="text" class="form-control  " name="title" value=""
                                                   data-required="true" >
                                        </div>
                                        <div class="col-md-12">
                                            <span class="help-block m-b-none">请输入模型的名称</span>
                                        </div>
                                    </div>

                                </div>
                            </div>
                            <div class="line line-dashed b-b line-lg pull-in"></div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">版本</label>

                                <div class="col-sm-10">
                                    <div class="row">
                                        <div class="col-md-4">
                                            <input type="text" class="form-control  " name="version" value=""
                                                   data-required="true" >
                                        </div>
                                        <div class="col-md-12 hide">
                                            <span class="help-block m-b-none">请输入模型的名称</span>
                                        </div>
                                    </div>

                                </div>
                            </div>
                            <div class="line line-dashed b-b line-lg pull-in"></div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">作者</label>

                                <div class="col-sm-10">
                                    <div class="row">
                                        <div class="col-md-4">
                                            <input type="text" class="form-control  " name="author" value="" data-required="true" >
                                        </div>
                                    </div>

                                </div>
                            </div>
                            <div class="line line-dashed b-b line-lg pull-in"></div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">模型类型</label>

                                <div class="col-sm-10">
                                    <div class="row">
                                        <div class="col-md-4 ">
                                            <label class="radio-inline i-checks">
                                                <input type="radio" value="0" name="extend" checked><i></i> 独立模型
                                            </label>
                                        </div>
                                        <div class="col-md-12">
                                            <span class="help-block m-b-none text-muted"><i class="fa fa-info-circle text-info"></i> 独立模型不会继承基础模型，是完全独立的表</span>

                                        </div>

                                    </div>
                                </div>
                            </div>
                            <div class="line line-dashed b-b line-lg pull-in"></div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">引擎类型</label>

                                <div class="col-sm-10">
                                    <div class="row">
                                        <div class="col-md-4 ">
                                            <select class="form-control " name="engine_type">
                                                <option value="InnoDB">InnoDB</option>
                                                <option value="MyISAM">MyISAM</option>
                                                <option value="MEMORY">MEMORY</option>
                                                <option value="BLACKHOLE">BLACKHOLE</option>
                                                <option value="MRG_MYISAM">MRG_MYISAM</option>
                                                <option value="ARCHIVE">ARCHIVE</option>
                                            </select>
                                        </div>
                                        <div class="col-md-12">
                                            <span class="help-block m-b-none"></span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="line line-dashed b-b line-lg pull-in"></div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">是否需要主键</label>

                                <div class="col-sm-10">
                                    <div class="row">
                                        <div class="col-md-4 ">
                                            <select class="form-control " name="need_pk">
                                                <option value="1" selected="selected">是</option>
                                                <option value="0">否</option>
                                            </select>
                                        </div>
                                        <div class="col-md-12">
                                            <span class="help-block m-b-none">选“是”则会新建默认的id字段作为主键</span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="line line-dashed b-b line-lg pull-in"></div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">是否开启话题</label>

                                <div class="col-sm-10">
                                    <div class="row">
                                        <div class="col-md-4 ">
                                            <select class="form-control " name="key_show">
                                                <option value="1" selected="selected">是</option>
                                                <option value="0">否</option>
                                            </select>
                                        </div>
                                        <div class="col-md-12">
                                            <span class="help-block m-b-none">选“是”,该模型会在话题模块中显示。</span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="line line-dashed b-b line-lg pull-in"></div>
                            <div class="form-group">
                            <label class="col-sm-2 control-label">是否开启模版</label>

                            <div class="col-sm-10">
                                <div class="row">
                                    <div class="col-md-4 ">
                                        <select class="form-control " name="temp_show">
                                            <option value="1" selected="selected">是</option>
                                            <option value="0">否</option>
                                        </select>
                                    </div>
                                    <div class="col-md-12">
                                        <span class="help-block m-b-none">选“是”,绑定该模版的栏目会显示模版的配置信息。<a href="#" class="text-info" >详细帮助</a></span>
                                    </div>
                                </div>
                            </div>
                        </div>
                            <div class="line line-dashed b-b line-lg pull-in"></div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">是否开启分组</label>

                                <div class="col-sm-10">
                                    <div class="row">
                                        <div class="col-md-4 ">
                                            <select class="form-control " name="groups_show">
                                                <option value="1" selected="selected">是</option>
                                                <option value="0">否</option>
                                            </select>
                                        </div>
                                        <div class="col-md-12">
                                            <span class="help-block m-b-none">选“是”,绑定该模型的栏目会显示分组的配置信息。<a href="#" class="text-info" >详细帮助</a></span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="line line-dashed b-b line-lg pull-in"></div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">是否开启分类信息</label>

                                <div class="col-sm-10">
                                    <div class="row">
                                        <div class="col-md-4 ">
                                            <select class="form-control " name="type_show">
                                                <option value="1" selected="selected">是</option>
                                                <option value="0">否</option>
                                            </select>
                                        </div>
                                        <div class="col-md-12">
                                            <span class="help-block m-b-none">选“是”,绑定该模型的栏目会显示分类信息的配置信息。<a href="#" class="text-info" >详细帮助</a></span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="line line-dashed b-b line-lg pull-in"></div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">是否开启权限管理</label>

                                <div class="col-sm-10">
                                    <div class="row">
                                        <div class="col-md-4 ">
                                            <select class="form-control " name="priv_show">
                                                <option value="1" selected="selected">是</option>
                                                <option value="0">否</option>
                                            </select>
                                        </div>
                                        <div class="col-md-12">
                                            <span class="help-block m-b-none">选“是”,绑定该模型的栏目会显示权限管理的配置信息。<a href="#" class="text-info" >详细帮助</a></span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group priv">
                                <label class="col-sm-2 control-label">角色权限配置</label>

                                <div class="col-sm-10">
                                    <div class="row">
                                        <div class="col-md-4 ">
                                            <textarea class="form-control" name="priv_roleid"  style="height: 100px"></textarea>
                                        </div>
                                        <div class="col-md-12">
                                            <span class="help-block m-b-none">开启权限管理才会生效，格式 <code>权限名(英文):说明</code>，多个换行,<a href="#" class="text-info" >详细帮助</a></span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group priv">
                                <label class="col-sm-2 control-label">会员组权限配置</label>

                                <div class="col-sm-10">
                                    <div class="row">
                                        <div class="col-md-4 ">
                                            <textarea class="form-control" name="priv_groupid"  style="height: 100px"></textarea>
                                        </div>
                                        <div class="col-md-12">
                                            <span class="help-block m-b-none">开启权限管理才会生效，格式 <code>权限名(英文):说明</code>，多个换行,<a href="#" class="text-info" >详细帮助</a></span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="line line-dashed b-b line-lg pull-in"></div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">是否开启审核</label>

                                <div class="col-sm-10">
                                    <div class="row">
                                        <div class="col-md-4 ">
                                            <select class="form-control " name="is_approval">
                                                <option value="1" {%if info.is_approval==1%} selected="selected"{%endif%}>是</option>
                                                <option value="0" {%if info.is_approval==0%} selected="selected"{%endif%}>否</option>
                                            </select>
                                        </div>
                                        <div class="col-md-12">
                                            <span class="help-block m-b-none">选“是”,该模型会在内容审核管理中显示。</span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="line line-dashed b-b line-lg pull-in"></div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">包含数据表</label>

                                <div class="col-sm-10">
                                    <div class="row">
                                        <div class="col-md-4">
                                            <input type="text" class="form-control " name="table" value="" >
                                        </div>
                                        <div class="col-md-12">
                                            <span class="help-block m-b-none">多个用','隔开，必填。</span>
                                        </div>
                                    </div>

                                </div>
                            </div>
                            <div class="line line-dashed b-b line-lg pull-in"></div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">实现的钩子方法</label>

                                <div class="col-sm-10">
                                    <div class="row">
                                        <div class="col-md-4 ">

                                            <select style="width:100%" name="hooks" class="chosen-select" multiple>
                                                {% for type, items in hooks | groupby("type") %}
                                                <optgroup label="{{'视图' if type==1 else '控制器'}}">
                                                    {% for item in items %}
                                                    <option value="{{ item.name }}"> {{ item.name }}</option>
                                                    {% endfor %}
                                                </optgroup>
                                                {% endfor %}
                                            </select>
                                        </div>
                                        <div class="col-md-12">
                                            <span class="help-block m-b-none text-muted"><i class="fa fa-info-circle text-info"></i> 实现的钩子方法</span>

                                        </div>

                                    </div>
                                </div>
                            </div>
                            <div class="line line-dashed b-b line-lg pull-in"></div>
                            <div class="form-group form-submit">
                                <div class="col-sm-4 col-sm-offset-2">
                                    <button class="btn btn-primary btn-s-md ajax-post" type="submit" target-form="form-horizontal">确定</button>
                                    <button class="btn btn-default" onclick="javascript:history.back(-1);return false;"
                                            type="submit">返回
                                    </button>

                                </div>
                            </div>
                        </form>
                    </div>
                </section>
            </div>
        </div>

    </section>
</section>

{% endblock%}

{% block script%}
<script src="/static/admin/js/parsley/parsley.min.js"></script>
<script src="/static/admin/js/parsley/parsley.extend.js"></script>
<script src="/static/admin/js/chosen/chosen.jquery.min.js"></script>
<script>
    $(function () {
        $("[name='priv_show']").change(function(){
            if($(this).val()==1){
                $(".priv").show();
            }else {
                $(".priv").hide();
            }

        });
    })
</script>
{% endblock%}